package exec.leetcode.october.two;


/**
 * <h1>#300 最长递增子序列</h1>
 * <a href = 'https://leetcode-cn.com/problems/longest-increasing-subsequence/'>题目</a>
 *
 * @author likeguo
 */
public class Main {
    public static void main(String[] args) {
        int[] matrix = {1, 2, 3, 4};
        System.out.println(new Main().lengthOfLIS(matrix));
    }

    public int lengthOfLIS(int[] nums) {
        if (nums.length == 0) {
            return 0;
        }
        int[] dp = new int[nums.length];
        dp[0] = 1;
        int maxans = 1;
        for (int i = 1; i < nums.length; i++) {
            dp[i] = 1;
            for (int j = 0; j < i; j++) {
                if (nums[i] > nums[j]) {
                    dp[i] = Math.max(dp[i], dp[j] + 1);
                }
            }
            maxans = Math.max(maxans, dp[i]);
        }
        return maxans;
    }


}
